home *** CD-ROM | disk | FTP | other *** search
- /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Copyright (C) 1995, by WATCOM International Inc. All rights %
- % reserved. No part of this software may be reproduced or %
- % used in any form or by any means - graphic, electronic or %
- % mechanical, including photocopying, recording, taping or %
- % information storage and retrieval systems - except with the %
- % written permission of WATCOM International Inc. %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- */
-
- #ifndef _WPALETTE_HPP_INCLUDED
- #define _WPALETTE_HPP_INCLUDED
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #ifndef _WOBJECT_HPP_INCLUDED
- # include "wobject.hpp"
- #endif
- #ifndef _WARRAY_HPP_INCLUDED
- # include "warray.hpp"
- #endif
- #ifndef _WCOLOR_HPP_INCLUDED
- # include "wcolor.hpp"
- #endif
-
- class WPaletteReference;
-
- enum WPaletteHandle { NULLHPALETTE = 0, LASTHPALETTE = LAST_16TO32BIT };
-
- class WCMCLASS WPalette : public WObject {
- WDeclareSubclass( WPalette, WObject );
-
- public:
-
- /************************************************************
- * Constructors and Destructors
- ************************************************************/
-
- WPalette();
- WPalette( const WPalette & palette );
- WPalette( const WColorArray & colorList );
- WPalette( const WPaletteHandle handle, WBool deleteHandle=FALSE );
-
- ~WPalette();
-
- /************************************************************
- * Properties
- ************************************************************/
-
- // Handle
-
- WPaletteHandle GetHandle() const;
-
- // Valid
- //
- // TRUE if palette was created/loaded.
-
- WBool GetValid() const { return GetHandle() != NULLHPALETTE; }
-
- /************************************************************
- * Methods
- ************************************************************/
-
- // Clear
- //
- // Set the palette to a null state. Deletes the palette
- // handle.
-
- void Clear();
-
- // Create
- //
- // Create a new palette. First clears old palette by calling
- // the Clear method.
-
- WBool Create( const WColorArray & colorList );
- WBool Create( const WPalette & palette );
- WBool Create( const WPaletteHandle handle, WBool deleteHandle=FALSE );
-
- /************************************************************
- * Static Methods
- ************************************************************/
-
- // IsValidHandle
- //
- // Returns TRUE if the given handle is valid. Can
- // optionally specify whether or not a null handle
- // is "valid".
-
- static WBool IsValidHandle( WPaletteHandle handle,
- WBool nullValid=FALSE );
-
- /************************************************************
- * Static Properties
- ************************************************************/
-
- // NullPalette
-
- static const WPalette & GetNullPalette();
-
- /************************************************************
- * Operators
- ************************************************************/
-
- WPalette & operator=( const WPalette & p );
-
- int operator==( const WPalette & p ) const;
- int operator!=( const WPalette & p ) const;
-
- /***********************************************************
- * Data members
- ***********************************************************/
-
- private:
-
- WPaletteReference * _ref;
- };
-
- #ifdef _DEBUG
- #define W_ISPALETTEHANDLE(h) CHECKGDI(WPalette::IsValidHandle((WPaletteHandle)h))
- #else
- #define W_ISPALETTEHANDLE(h)
- #endif
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WPALETTE_HPP_INCLUDED
-